package com.csun.cmny.provider.controller.admin;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.model.dto.card.PointCardBindDto;
import com.csun.cmny.provider.model.dto.card.PointCardBindQueryDto;
import com.csun.cmny.provider.model.vo.card.PointCardBindVO;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.DmcPointCardBindService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.github.pagehelper.PageInfo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/pointCardBind", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DmcPointCardBindController extends BaseController {

    @Resource
    private DmcPointCardBindService dmcPointCardBindService;
    @Resource
    private CmnyMessageSource cmnyMessageSource;

    /**
     * 一卡通管理 绑定
     *
     * @param pointCardBindDto
     * @return the wrapper
     */
    @RequestMapping(value = "/bind", method = RequestMethod.POST)
    public Wrapper bind(@RequestBody PointCardBindDto pointCardBindDto) {
        int i = dmcPointCardBindService.bind(pointCardBindDto,getLoginAuthDto());
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),null);
    }

    /**
     * 一卡通管理 解绑
     *
     * @param deviceId
     * @return the wrapper
     */
    @RequestMapping(value = "/unbind/{deviceId}", method = RequestMethod.POST)
    public Wrapper unbind(@PathVariable Long deviceId) {
        int i = dmcPointCardBindService.unbind(deviceId);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
    }

    /**
     * 一卡通管理-冻结
     *
     * @param deviceId
     * @return the wrapper
     */
//    @RequestMapping(value = "/freeze/{deviceId}", method = RequestMethod.POST)
//    public Wrapper freeze(@PathVariable Long deviceId) {
//        int i = dmcPointCardBindService.freeze(deviceId);
//        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
//    }

    /**
     * 一卡通管理-解冻
     *
     * @param deviceId
     * @return the wrapper
     */
//    @RequestMapping(value = "/unfreeze/{deviceId}", method = RequestMethod.POST)
//    public Wrapper unfreeze(@PathVariable Long deviceId) {
//        int i = dmcPointCardBindService.unfreeze(deviceId);
//        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
//    }

    /**
     * 一卡通管理-退卡
     *
     * @param deviceId
     * @return the wrapper
     */
//    @RequestMapping(value = "/refund/{deviceId}", method = RequestMethod.POST)
//    public Wrapper refund(@PathVariable Long deviceId) {
//        int i = dmcPointCardBindService.refund(deviceId);
//        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),i);
//    }

    /**
     * 一卡通管理-补办新卡
     *
     * @param deviceId
     * @return the wrapper
     */
//    @RequestMapping(value = "/reissue/{deviceId}", method = RequestMethod.POST)
//    public Wrapper reissue(@PathVariable Long deviceId) {
//        int i = dmcPointCardBindService.reissue(deviceId);
//        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),null);
//    }

    /**
     * 一卡通管理-分页查询
     *
     * @param pointCardBindQueryDto
     * @return the wrapper
     */
    @RequestMapping(value = "/listPage", method = RequestMethod.POST)
    public Wrapper listPage(@RequestBody PointCardBindQueryDto pointCardBindQueryDto) {
        PageInfo<PointCardBindVO> pageInfo = dmcPointCardBindService.listPage(pointCardBindQueryDto);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),pageInfo);
    }

    /**
     * 一卡通管理-查询未绑定的卡
     *
     * @param pointCardBindQueryDto
     * @return the wrapper
     */
//    @RequestMapping(value = "/listUnbindCard", method = RequestMethod.POST)
//    public Wrapper listUnbindCard(@RequestBody PointCardBindQueryDto pointCardBindQueryDto) {
//        List<PointCardBindVO> voList = dmcPointCardBindService.listUnbindCard(pointCardBindQueryDto);
//        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),voList);
//    }

}
